﻿<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="~/_controltemplates/InputFormSection.ascx" %> 
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="~/_controltemplates/ButtonSection.ascx" %>
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomLobSystemData.aspx.cs" Inherits="TFSWITConnector.CustomLobSystemData" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    <SharePoint:EncodedLiteral ID="EncodedLiteral1" runat="server" Text="TFS/SP Connector Administration" EncodeMethod='HtmlEncode' />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
    <SharePoint:EncodedLiteral ID="EncodedLiteral2" runat="server" Text="TFS/SP Connector Administration" EncodeMethod='HtmlEncode' />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderPageDescription" runat="server">
    <SharePoint:EncodedLiteral ID="EncodedLiteral3" runat="server" Text="Use this page to configure TFS/SP Connector Project." EncodeMethod='HtmlEncodeAllowSimpleTextFormatting' />
</asp:Content>
<asp:Content ID="Content4" contentplaceholderid="PlaceHolderMain" runat="server">
<script type="text/javascript" >
    function btnConnectionTestClick() {
        var btn = document.getElementById('btnConnectionTest');
        btn.disabled = "disabled";

        var script = document.createElement('script');
        script.src = '/_layouts/TFSSPConnector/jquery-1.9.0.min.js';
        script.type = 'text/javascript';
        script.onreadystatechange = function () { ValidateTFSConnection(); };
        script.onload = function () { ValidateTFSConnection(); };
        document.getElementsByTagName('head')[0].appendChild(script);
    }
    function ValidateTFSConnection() {
        var url = document.getElementById('<%=this.txtLobSystem_TFSServerURL.ClientID%>').value;

        var sssSelector = document.getElementById('<%=this.sssUserSelector2.ClientID%>');
        var user = sssSelector.options[sssSelector.selectedIndex].value;

        var cred = document.getElementById('<%=this.rdbSSS2.ClientID%>').getAttribute("checked");
        if (cred != "checked") user = "";
        
        dlg = myShowWaitScreenWithNoClose('Please Wait...', "Processing request.");
        $.ajax({
            type: "POST",
            url: "/_layouts/TFSSPConnector/CustomLobSystemData.aspx/ValidateTFSConnection",
            data: '{"url":"' + url + '", "user":"' + user + '"}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) { dlg.close(); SuccessCallBack(data); },
            error: function (data) { dlg.close(); FailureCallBack(data); }
        });
    }
    function SuccessCallBack(data) {
        var btn = document.getElementById('btnConnectionTest');
        btn.removeAttribute("disabled");

        //alert(data.d);
        SP.UI.Notify.addNotification(data.d, true);
    }
    function FailureCallBack(data) {
        var btn = document.getElementById('btnConnectionTest');
        btn.removeAttribute("disabled");

        //alert(data.status + " : " + data.statusText);
        SP.UI.Notify.addNotification(data.status + " : " + data.statusText, true);
    }
    function myShowWaitScreenWithNoClose(title, message) {
        return SP.UI.ModalDialog.$1I_1(title, message, false, false, null, null, 270, '12px 12px 4px 6px', 0);
    }
    function rdbCredentialsClick(action) {
        if (action == "disabled") {
            document.getElementById('<%=this.sssUserSelector2.ClientID%>').setAttribute("disabled", "disabled");
        }
        else {
            document.getElementById('<%=this.sssUserSelector2.ClientID%>').removeAttribute("disabled");
        }
    }
</script>
<table cellspacing="0" cellpadding="0" border="0" class="ms-settingsframe">
    <tr>
      <td width="100%" colspan="4" style="padding-top: 0px;">
        <table class="ms-pageinformation" width="100%" cellpadding="0" cellspacing="0">
          <tr>
            <td valign="top" style="padding: 10px;" width="100%" height="100px">
              <table width="100%" id="idItemHoverTable">
                <tr>
                  <th scope="col" colspan="2" style="padding-bottom: 8px;">
                    <!--span class="ms-linksectionheader"-->
                      <h3 class="ms-standardheader">
                        <SharePoint:EncodedLiteral ID="EncodedLiteral4" runat="server" Text="Administration page for setting BDC External System properties" EncodeMethod='HtmlEncode' />
                      </h3>
                  </th>
                </tr>
                <tr>
                  <th scope="row" nowrap="nowrap">
                    <SharePoint:EncodedLiteral ID="EncodedLiteral5" runat="server" Text="<% $Resources:wss,settings_siteurl %>" EncodeMethod='HtmlEncode' />:
                  </th>
                  <td dir="ltr">
                    <% SPHttpUtility.HtmlEncode(Web.Url + "/", Response.Output); %>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td valign="top" style="padding: 4px 0px 4px 0px;" height="100%">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ms-propertysheet">
           <colgroup>
              <col style="width: 40%" />
              <col style="width: 60%" />
           </colgroup>
           <tr>
              <td>
           <wssuc:InputFormSection Collapsible="true" Title="BDC External System Settings" id="prpLobSystem" Description="BDC External System Setting" runat="server">
            <template_inputformcontrols>            
             <wssuc:InputFormControl ID="ifrLobSystem_TFSServerURL" LabelText="TFS connection URL" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtLobSystem_TFSServerURL" Runat="server" Columns="60" />
                <SharePoint:InputFormRequiredFieldValidator ID="vldLobSystem_TFSServerURL" ControlToValidate="txtLobSystem_TFSServerURL" Text="Enter connection URL for TeamSystem Foundation Server" runat="server" ErrorMessage ="Required" EnableClientScript="true" Display="Dynamic"/>
                <input type="button" id="btnConnectionTest" name="btnConnectionTest" onclick="btnConnectionTestClick();" value="Test Connection" />
                </div>
              </Template_Control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl ID="ifrLobSystem_TFSCredentials" LabelText="TFS connection credentials" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
              <input runat="server" type="radio" id="rdbSPU2" name="SSSTfsCred" value="SPU" onclick="rdbCredentialsClick('disabled');" />Connect with Current User Identity</br>
              <input runat="server" type="radio" id="rdbSSS2" name="SSSTfsCred" value="SSS" onclick="rdbCredentialsClick('enabled');" />Connect with Impersonated Windows Identity</br>
              Secure Store Application ID:
              <select runat="server" id="sssUserSelector2" name="sssUserSelector2" style="width: 40ex">
                    <option></option>
              </select>
              </div></Template_Control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl ID="ifrLobSystem_TFSProjectName" LabelText="TFS Project Name" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtLobSystem_TFSProjectName" Runat="server" Columns="60" />
                <SharePoint:InputFormRequiredFieldValidator ID="vldLobSystem_TFSProjectName" ControlToValidate="txtLobSystem_TFSProjectName" Text="Enter TFS Project Name" runat="server" ErrorMessage ="Required" EnableClientScript="true" Display="Dynamic"/>
              </div></Template_Control>
            </wssuc:InputFormControl> 
            <wssuc:InputFormControl ID="ifrLobSystem_Name" LabelText="External System Name" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtLobSystem_Name" Runat="server" Columns="60" />
                <SharePoint:InputFormRequiredFieldValidator ID="vldLobSystem_Name" ControlToValidate="txtLobSystem_Name" Text="Enter External System name" runat="server" ErrorMessage ="Required" EnableClientScript="true" Display="Dynamic"/>
              </div></Template_Control>
            </wssuc:InputFormControl> 
            </template_inputformcontrols>
          </wssuc:InputFormSection>
          <wssuc:InputFormSection Collapsible="true" Title="WorkItem Settings" id="prpWorkItem" Description="WorkItem Setting" runat="server">
            <template_inputformcontrols>            
             <wssuc:InputFormControl ID="ifrWorkItem_RequiredInForms" LabelText="Required Fields" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtWorkItem_RequiredInForms" Runat="server" Columns="60" />
                <SharePoint:InputFormRequiredFieldValidator ID="vldWorkItem_RequiredInForms" ControlToValidate="txtWorkItem_RequiredInForms" Text="Enter comma-separated list of required fields" runat="server" ErrorMessage ="Required" EnableClientScript="true" Display="Dynamic"/>
              </div></Template_Control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl ID="ifrWorkItem_ShowInListView" LabelText="Fields shown in List View" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtWorkItem_ShowInListView" Runat="server" Columns="60" />
              </div></Template_Control>
            </wssuc:InputFormControl> 
            <wssuc:InputFormControl ID="ifrWorkItem_ShowInItemView" LabelText="Fields shown in Item View" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtWorkItem_ShowInItemView" Runat="server" Columns="60" />
              </div></Template_Control>
            </wssuc:InputFormControl> 
            <wssuc:InputFormControl ID="ifrWorkItem_ReadOnlyFields" LabelText="ReadOnly Fields" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtWorkItem_ReadOnlyFields" Runat="server" Columns="60" />
              </div></Template_Control>
            </wssuc:InputFormControl> 
            </template_inputformcontrols>
          </wssuc:InputFormSection>
          <wssuc:InputFormSection Collapsible="true" Title="Attachment Settings" id="prpAttachment" Description="Attachment Setting" runat="server">
            <template_inputformcontrols>            
             <wssuc:InputFormControl ID="ifrAttachment_ShowInListView" LabelText="Fields shown in List View" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtAttachment_ShowInListView" Runat="server" Columns="60" />
              </div></Template_Control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl ID="ifrAttachment_ShowInItemView" LabelText="Fields shown in Item View" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtAttachment_ShowInItemView" Runat="server" Columns="60" />
              </div></Template_Control>
            </wssuc:InputFormControl> 
            <wssuc:InputFormControl ID="ifrAttachment_EntityName" LabelText="Attachments ECT Name" runat="server">
              <Template_Control>
              <div class="ms-authoringcontrols">
                <SharePoint:InputFormTextBox CssClass="ms-input" ID="txtAttachment_EntityName" Runat="server" Columns="60" />
                <SharePoint:InputFormRequiredFieldValidator ID="vldAttachment_EntityName" ControlToValidate="txtAttachment_EntityName" Text="Enter Attachments ECT Name" runat="server" ErrorMessage ="Required" EnableClientScript="true" Display="Dynamic"/>
              </div></Template_Control>
            </wssuc:InputFormControl> 
            </template_inputformcontrols>
          </wssuc:InputFormSection>
          <wssuc:ButtonSection ID="ButtonSection1" runat="server" ShowStandardCancelButton="false" ShowSectionLine="true">
            <Template_Buttons>
                <asp:Button UseSubmitBehavior="false" runat="server" Text="<%$Resources:wss,multipages_okbutton_text%>" id="btnSubmit" accesskey="<%$Resources:wss,okbutton_accesskey%>" Enabled="true" OnClick="btnSubmit_Click"/>
                <asp:Button UseSubmitBehavior="false" runat="server" Text="<%$Resources:wss,multipages_cancelbutton_text%>" id="btnCancel" accesskey="<%$Resources:wss,cancelbutton_accesskey%>" Enabled="true" OnClick="btnCancel_Click"/>
            </Template_Buttons>
          </wssuc:ButtonSection>
          </td></tr>
          <tr>  
          <td class="ms-sectionline" height="2" colspan="2">   
          <img width="1" height="1" src="/_layouts/images/blank.gif" alt="blank"/>  
          </td> 
          </tr>
       </table>
      </td>
    </tr>
  </table>
</asp:Content>